<template>
	<view class="comment-input-box">
		<input focus :value="innerValue" type="text" @change="handleChange" @confirm="confirm" @blur="blur" />
		<button @click="confirm">发送</button>
	</view>
</template>
<script>
	export default {
		props: {
			modelValue: {
				type: [String, Number],
				default: ''
			},
			value: {
				type: [String, Number],
				default: ''
			},
		},
		model: {
			prop: 'value',
			event: 'input'
		},
		computed: {
			innerValue() {
				// #ifdef VUE2
				return this.value
				// #endif
				// #ifdef VUE3
				return this.modelValue
				// #endif
			}
		},
		methods: {
			handleChange: function(e) {
				this.$emit('update:modelValue', e.detail.value)
				this.$emit('input', e.detail.value)
				this.$emit('change', e)
			},
			confirm: function() {
				this.$emit('confirm')
			},
			blur: function() {
				setTimeout(() => {
					this.$emit('blur')
				}, 500)
			}
		}
	}
</script>
<style lang="scss" scoped>
	.comment-input-box {
		position: fixed;
		bottom: 0;
		z-index: 9999;
		height: 75px;
		width: 100%;
		left: 0;
		right: 0;
		background-color: #DBE2E2;
		display: flex;
		padding: 10px;
		box-sizing: border-box;

		input {
			flex: 1;
			height: 40px;
			padding: 0 8px;
			background-color: #fff;
			border-radius: 4px;
			margin-right: 6px;
		}

		button {
			height: 40px;
			display: flex;
			align-items: center;
			padding: 0 14px;
			font-size: 14px;
			color: #656F78;
		}
	}
</style>